const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const ChatSchema = new Schema({
    // 群组与个人的需要区分
    id: String, // a发给b的与b发给a的chat_id应一致
    // from 与 to是相对的
    from: Schema.Types.ObjectId,
    to: Schema.Types.ObjectId,
    create_time: {
        type: Date,
        default: Date.now
    },
    type: {
        type: String,
        enum: ['group', 'person'],
        default: 'person'
    }
});

const Chat = mongoose.model('Chat', ChatSchema);

module.exports = Chat;